<?php
namespace app\admin\controller;

use app\admin\services\WxDialogService;
use app\common\controller\Base;

class WxDialog extends Base
{
    /**
     * @var WxDialogService
     */
    protected $_service;

    protected function _setService()
    {
        $this->_service = new WxDialogService();
    }

    public function talk()
    {
        $id = I('get.dialog_id', 0, 'intval');//dialog_id
        $_GET['id'] = $id;
        return $this->fetch('wxDialog/talk');
    }

    public function getDialogMessages()
    {
        $dialog_id = I('get.id', 0, 'intval');
        return $this->commonData($this->_service->getDialogMessages($dialog_id));
    }

    public function sendToDialog()
    {
        return $this->commonData($this->_service->sendToDialog($_POST));
    }

    public function getNewMessages()
    {
        return $this->commonData($this->_service->getNewMessages($_GET));
    }
}